import { Controller,Post, Body, Req } from '@nestjs/common';
import { ArticleService } from './article.service';
import { CreateArticleDto, DeleteArticleDto, EditArticleDto, FindKeyArticleDto, FindManyDto } from './dto/article.dto';
import { FastifyRequest } from 'fastify';

@Controller('article')
export class ArticleController {
  constructor(private readonly articleService: ArticleService) { }

  @Post('create')
  create(@Body() cad: CreateArticleDto) {
    return this.articleService.create(cad);
  }

  @Post('findMany')
  findMany(@Body() fmd: FindManyDto) {
    return this.articleService.findMany(fmd);
  }

  @Post('findKeyArticle')
  findKeyArticle(@Body() fkad: FindKeyArticleDto) {
    return this.articleService.findKeyArticle(fkad);
  }

  @Post('edit')
  edit(@Body() ead: EditArticleDto) {
    return this.articleService.edit(ead);
  }

  @Post('delete')
  delete(@Body() dad: DeleteArticleDto) {
    return this.articleService.delete(dad);
  }

  // 上传单个文件
  @Post('uploadSingleFile')
  uploadSingleFile(@Req() req: FastifyRequest) {
    return this.articleService.uploadSingleFile(req);
  }
}
